<?php

namespace app\controllers;

use app\controllers\action\Student;
use app\controllers\action\Teacher;
use core\controller\Controller;
use db\Conn;

class update_student_info implements Controller
{
    public static function execute()
    {
        $return = ["code" => 400, "data" => [], "msg" => "更新学生信息失败"];
        $conn = Conn::execute();
        if ($_SESSION["user_type"] == "teacher") {
            if(Teacher::update_student_info($conn, $_POST["student_id"],$_POST["student_name"], $_POST["student_sex"],$_POST["description"])) {
                $return["code"] = 200;
                $return["msg"] = "更新学生信息成功";
            }
        } else if ($_SESSION["user_type"] == "student") {
            if (Teacher::update_student_info($conn, $_SESSION["student_id"],$_POST["student_name"], $_POST["student_sex"],$_POST["description"])) {
                $return["code"] = 200;
                $return["msg"] = "更新学生信息成功";
            }
        }
        $conn->close();

        return $return;
    }
}